package gientech.spring.demo.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import gientech.spring.demo.entity.User;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;


@Mapper
@Repository
public interface UserMapper extends BaseMapper<User> {

    /**
     * 查询某事务记录是否已执行
     * @param txNo 事务编号
     * @return
     */
    @Select("select count(1) from de_duplication where tx_no = #{txNo}")
    int isExistTx(long txNo);

    /**
     * 保存某事务执行记录
     * @param txNo 事务编号
     * @return
     */
    @Insert("insert into de_duplication values(#{txNo},now());")
    int addTx(long txNo);


    @Update("UPDATE user\n" +
            "SET  u_username=#{username} \n" +
            "WHERE u_id=#{id};\n")
    int updateById(@Param("id") String id, @Param("username") String username);





}




